//
//  HomeViewController.m
//  sleepTest2
//
//  Created by apple on 2017/8/5.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HomeViewController.h"
#import "HelpViewController.h"
#import "RootViewController.h"
#import "commentsViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 为页面添加标题和背景色
    self.title = @"主页";
    self.view.backgroundColor = [UIColor colorWithRed:34/255.0 green:38/255.0 blue:65/255.0 alpha:1];
    
    // 帮助中心pushButton
    UIButton *helpBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    helpBtn.frame = CGRectMake(0,70, 80, 30);
    [helpBtn setTitle:@"帮助中心" forState:UIControlStateNormal];
    [helpBtn setTintColor:[UIColor colorWithRed:188/255.0 green:195/255.0 blue:232/255.0 alpha:1]];
    [helpBtn addTarget:self action:@selector(helpBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:helpBtn];
    
    // 意见反馈pushButton
    UIButton *commentsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    commentsBtn.frame = CGRectMake(0, 100, 80, 30);
    [commentsBtn setTitle:@"意见反馈" forState:UIControlStateNormal];
    [commentsBtn setTintColor:[UIColor colorWithRed:188/255.0 green:195/255.0 blue:232/255.0 alpha:1]];
    [commentsBtn addTarget:self action:@selector(commentsBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:commentsBtn];
    
}

// 帮助中心按钮点击事件
- (void)helpBtnAction{
    HelpViewController *helpVC = [[HelpViewController alloc] init];
    // 跳转
    [self.navigationController pushViewController:helpVC animated:YES];
    
    // 将系统默认的tabBar设置为自己的
    RootViewController *rootVC = (RootViewController *)self.tabBarController;
    [rootVC showTabBar:NO];
}

// 意见反馈按钮点击事件
- (void)commentsBtnAction{
    commentsViewController *commentsVC = [[commentsViewController alloc] init];
    // 跳转
    [self.navigationController pushViewController:commentsVC animated:YES];
    
    //
    RootViewController *rootVC = (RootViewController *)self.tabBarController;
    [rootVC showTabBar:NO];
}

// 从push界面返回时，重新显示标签栏
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    // 获取根视图控制器
    RootViewController *rootVC = (RootViewController *) self.tabBarController;
    [rootVC showTabBar:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
